package com.pr.makfilm.domain;

import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.Length;
import org.joda.time.DateTime;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 17.09.13
 * Time: 23:05
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "event")
public class Event extends IdentifiableEntity
{
   public static final String FIELD_NAME = "name";

   public static final String FIELD_ROOM = "room";

   public static final String FIELD_DATE_TIME = "dateTime";

   public static final String FIELD_DESCRIPTION = "description";

   public static final String FIELD_PRICE = "price";

   public static final int MAX_LENGTH_NAME = 50;

   @Id
   @GeneratedValue
   @Column
   private Long id;

   @Column(nullable = false, length = MAX_LENGTH_NAME)
   @NotNull
   @Length(max = MAX_LENGTH_NAME)
   private String name;

   @ManyToOne(cascade = {CascadeType.MERGE, CascadeType.PERSIST}, fetch = FetchType.LAZY)
   @JoinColumn(nullable = false)
   @NotNull
   private Room room;

   @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
   @Column(name = "date_time", nullable = false)
   @NotNull
   private DateTime dateTime;

   @Column(nullable = true)
   private String description;

   @Column(nullable = false)
   @NotNull
   private Double price;

   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public Room getRoom()
   {
      return room;
   }

   public void setRoom(Room room)
   {
      this.room = room;
   }

   public DateTime getDateTime()
   {
      return dateTime;
   }

   public void setDateTime(DateTime dateTime)
   {
      this.dateTime = dateTime;
   }

   public String getDescription()
   {
      return description;
   }

   public void setDescription(String description)
   {
      this.description = description;
   }

   public Double getPrice()
   {
      return price;
   }

   public void setPrice(Double price)
   {
      this.price = price;
   }
}
